# -*- coding: utf-8 -*-

"""StaffLog - Terminal
@version: 0.1
@license: GPL 3.0 (see "license" file)
@author: Jose A. Jimenez <jajimc@gmail.com>, Miguel Centeno <miguelcent@gmail.com>"""

import sys
import xmlrpclib

def set_up(host, port, userId, userPassword, eyesDistance, horLeftEyeNoseDistance, verLeftEyeNoseDistance, noseMouthDistance):
    success = False
        
    try:
        clientProxy = xmlrpclib.ServerProxy("http://%s:%d" % (host, port))
        args = [eyesDistance, horLeftEyeNoseDistance, verLeftEyeNoseDistance, noseMouthDistance]
        clientProxy.run_callable_authenticated_service("stafflog_setup", args, userId, userPassword)
        success = True
    except:
        pass

    return success
    
def checkin(host, port, eyesDistance, horLeftEyeNoseDistance, verLeftEyeNoseDistance, noseMouthDistance):
    user = ""

    try:
        clientProxy = xmlrpclib.ServerProxy("http://%s:%d" % (host, port))
        args = [eyesDistance, horLeftEyeNoseDistance, verLeftEyeNoseDistance, noseMouthDistance]
        user = clientProxy.run_callable_authenticated_service("stafflog_checkin", args, "stafflog_checkin", "stafflog_checkin")
    except:
        pass

    return user
